package com.johnconnor.springcloudauthorizationserver.controller;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.Collections;

@RestController
@Slf4j
public class UserController {

    @GetMapping(value = "/user",produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<Principal> getUser(Principal principal){
        System.err.println(String.join("", Collections.nCopies(100, "-")));
        System.err.println(JSONObject.toJSONString(principal,true));
        System.err.println(String.join("", Collections.nCopies(100, "-")));
        return new ResponseEntity<>(principal, HttpStatus.OK);
    }
}
